from django.contrib import admin
from . import models
from django import forms
from KeHu.models import KeHu
from ChanPin.models import Dingdan
from django.contrib.auth.models import User
# Register your models here.
from .models import xueyuan_jiaowu_genjinlog



@admin.register(models.Banji)
class tzzy_banjiAdmin(admin.ModelAdmin):
    list_display = ('id', 'name')
    list_filter = ('name', )
    search_fields = ('name', )
    ordering = ('-id', )
    filter_horizontal = ('xueyuan', 'banji_leader','banji_chanpin')
    list_display_links = ('name','id', )

# @admin.register(models.tzzy_xueyuan)
# class tzzy_xueyuanAdmin(admin.ModelAdmin):banji_chanpin
#     list_display = ('kehu', 'xueyuan_jinbantime')
#     list_filter = ('kehu', )
#     search_fields = ('kehu', )
#     ordering = ('-xueyuan_jinbantime', )
#     widgets = {
#         'xueyuan_jinbantime': forms.SelectDateWidget,
#
#     }

# @admin.register(models.Xueli_Banji)
# class xueli_banjiAdmin(admin.ModelAdmin):
#     list_display = ('id', 'name','banji_leibie')
#     list_filter = ('name', )
#     search_fields = ('name', )
#     ordering = ('-id', )
#     filter_horizontal = ('xueyuan', )
#     list_display_links = ('name','id', )
#
#     def get_form(self, request, obj=None, **kwargs):
#         form = super().get_form(request, obj, **kwargs)
#         form.base_fields['fuzelaoshi'].queryset = User.objects.filter(groups='2')
#         return form

# @admin.register(models.Xueli_xueyuan)
# class Xueli_xueyuanAdmin(admin.ModelAdmin):
#     list_display = ('kehu', 'xueyuan_jinbantime')
#     list_filter = ('kehu', )
#     search_fields = ('kehu', )
#     ordering = ('-xueyuan_jinbantime', )
#     widgets = {
#         'xueyuan_jinbantime': forms.SelectDateWidget,
#
#     }

@admin.register(models.Xueyuan_zongbiao)
class Xueyuan_zong_Admin(admin.ModelAdmin):
        list_display = ('kehu', 'xueyuan_jinbantime',)
        list_filter = ('kehu',)
        search_fields = ('kehu',)
        ordering = ('-xueyuan_jinbantime',)
        widgets = {
            'xueyuan_jinbantime': forms.SelectDateWidget,

        }


@admin.register(models.xueyuan_jiaowu_genjinlog)
class xueyuan_jiaowu_genjinlogAdmin(admin.ModelAdmin):
    list_display = ('id', 'kehu', 'gengjin_time', 'addlog_user', 'gengjin_content')
    list_filter = ('kehu', )
    search_fields = ('kehu', )
    ordering = ('-gengjin_time', )


@admin.register(models.Xueyuan_Zilao)
class Xueyuan_ZilaoAdmin(admin.ModelAdmin):
    list_display = ('id', 'xueyuan','xm', 'xb', 'zzmm')
    list_filter = ('xueyuan', )
    search_fields = ('xueyuan', )
    ordering = ('-id', )